package com.czx.controller;

import com.czx.entity.MyPage;
import com.czx.service.DiscussPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;


@Controller
public class PageController {
    @Autowired
    private DiscussPostService dps;

//   @Value("${blog.host}")
//   private String host;
//
//    @Value("${server.port}")
//    private Integer port;

    @RequestMapping("/")
    public String getIndex(MyPage page, Model model, Integer orderMode, ModelMap modelMap) {
        page =dps.disCussPage(page,orderMode);
        model.addAttribute("page", page);
        page.setPath("/index");
//        String baseUrl = " http://zt9tcc.natappfree.cc";
//        modelMap.put("baseUrl", baseUrl);
        return "index";
    }
    @RequestMapping("/{page}.html")
    public String toPage(@PathVariable String page) {
        System.out.println("page = " + page);
        return page;
    }

    @RequestMapping("/{path}/{page}.html")
    public String toPage2(@PathVariable String path, @PathVariable String page) {
        System.out.println("path = " + path + ", page = " + page);
        return path + "/" + page;
    }
}
